package com.rpp.dao;

import com.rpp.domain.Order;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description
 * @Author peng
 * @Date 2020/10/28 10:53 上午
 */
public interface OrderRepository extends JpaRepository<Order, Long> {

    @Modifying
    @Transactional(rollbackFor = Exception.class, timeout = 30, isolation = Isolation.READ_COMMITTED)
    @Query(value = "update Order set status = ?2 where id = ?1")
    int updateOrderStatus(Long orderId, String status);
}
